home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / usenet / volume6 / conquer4 / patch6a < prev    next >
Encoding:
Internet Message Format  |  1989-10-02  |  50.4 KB

  1. Path: uunet!zephyr.ens.tek.com!tekgen!tekred!saab!billr
  2. From: billr@saab.CNA.TEK.COM (Bill Randle)
  3. Newsgroups: comp.sources.games
  4. Subject: v08i032:  conquer4 - middle earth multi-player game (V4), Patch6a
  5. Message-ID: <4600@tekred.CNA.TEK.COM>
  6. Date: 21 Sep 89 13:13:32 GMT
  7. Sender: news@tekred.CNA.TEK.COM
  8. Lines: 1693
  9. Approved: billr@saab.CNA.TEK.COM
  10.  
  11. Submitted-by: Adam Bryant <adb@bu-cs.bu.edu>
  12. Posting-number: Volume 8, Issue 32
  13. Archive-name: conquer4/Patch6a
  14. Patch-To: conquer4: Volume 6, Issue 83-96
  15.  
  16.     [The latest (#6) conquer patches in four parts.    -br]
  17.  
  18. [[What is included in this patch:
  19.  
  20.      - A rehashing of the mail program
  21.      - A possible fix for the 'moving to their Capitol' error
  22.      - More display enhancements
  23.      - The conqrast program to display map images on the sun.
  24.      - A new poverty and inflation methodology.  [Warning!! Watch your budget!!]
  25.      - MORE STUFF THAT I CAN'T QUITE REMEMBER NOW!!!!!
  26.  
  27. Instructions:
  28.      1) MAKE A SUBDIRECTORY IN THE CONQUER SOURCE DIRECTORY
  29.        [Suggest you call it conqrast...]
  30.      2) UNSHAR ALL OF THE PARTS IN THIS DIRECTORY
  31.      3) MOVE 'patchV4.6' TO THE CONQUER SOURCE DIRECTORY
  32.      4) 'patch < patchV4.6' TO APPLY IT
  33.      5) THE SUBDIRECTORY CONTAINS THE CODE TO THE CONQRAST PROGRAM
  34.  
  35. Hopefully this is enough to get everything going.
  36.  
  37. Once again, the more detailed fix list is in notes.v4.
  38.  
  39. adam
  40. Adam Bryant                               ARPA:   adb@bu-cs.bu.edu
  41. Conquer Hack'n'Slasher                    BITNET: adb@buenga
  42. list: conquer-news-request@bu-cs.bu.edu   UUCP:   ...!harvard!bu-cs!adb]]
  43.  
  44. #!/bin/sh
  45. # shar:    Shell Archiver  (v1.22)
  46. #
  47. # This is part 1 of a multipart archive                                    
  48. # do not concatenate these parts, unpack them in order with /bin/sh        
  49. #
  50. #    Run the following text with /bin/sh to create:
  51. #      Makefile
  52. #      README
  53. #      conqrast.c
  54. #      conqrast.man
  55. #      error.c
  56. #      file.c
  57. #      file.h
  58. #      patchV4.6
  59. #      sunconqrast.h
  60. #      sunstuff.c
  61. #      util.c
  62. #      xconqrast.h
  63. #      xstuff.c
  64. #
  65. if test -r s2_seq_.tmp
  66. then echo "Must unpack archives in sequence!"
  67.      next=`cat s2_seq_.tmp`; echo "Please unpack part $next next"
  68.      exit 1; fi
  69. sed 's/^X//' << 'SHAR_EOF' > Makefile &&
  70. X#
  71. XSHELL=/bin/sh
  72. XSHAR=/usr/local/bin/shar
  73. XMAKE=/bin/make
  74. X
  75. X#
  76. X# Will most likely have to edit the location of the
  77. X# X Libraries.
  78. X#
  79. XLibs_sun= -lpixrect
  80. XLibs_x= -L/usr/lib -lX
  81. X
  82. XWHICHconqrast: WHICHconqrast.o error.o WHICHstuff.o file.o util.o
  83. X    cc $(CFLAGS) -o WHICHconqrast WHICHconqrast.o WHICHstuff.o file.o\
  84. X            util.o error.o $(Libs_WHICH)
  85. X
  86. Xerror.o: error.c
  87. Xfile.o: file.c
  88. Xutil.o:util.c
  89. X
  90. XWHICHconqrast.o: conqrast.c WHICHconqrast.h file.h ../header.h
  91. X    $(CC) $(CFLAGS) -c conqrast.c -DHEADERFILE=\"WHICHconqrast.h\"
  92. X    mv conqrast.o WHICHconqrast.o
  93. X
  94. XWHICHstuff.o: WHICHstuff.c WHICHconqrast.h
  95. X
  96. Xlint.WHICH:
  97. X    lint -abchx -DHEADERFILE=\"WHICHconqrast.h\" \
  98. X        conqrast.c WHICHstuff.c error.c file.c util.c $(Libs_WHICH)
  99. X
  100. X### don't delete this line!
  101. X
  102. Xall: sunconqrast xconqrast
  103. X
  104. Xlint: lint.sun lint.x
  105. X
  106. Xlint.sun: makefile.sun 
  107. X    $(MAKE) $(MFLAGS) -f makefile.sun lint.sun
  108. X
  109. Xlint.x: makefile.x 
  110. X    $(MAKE) $(MFLAGS) -f makefile.x lint.x
  111. X
  112. Xsun sunconqrast: makefile.sun conqrast.c sunstuff.c sunconqrast.h file.c\
  113. X            file.h util.c
  114. X    $(MAKE) $(MFLAGS) -f makefile.sun sunconqrast
  115. X
  116. Xmakefile.sun : Makefile
  117. X    sed -e '/^###/q' -e '/WHICH/s//sun/g' Makefile > makefile.sun
  118. X
  119. Xx xconqrast: makefile.x conqrast.c xstuff.c xconqrast.h file.c file.h util.c
  120. X    $(MAKE) $(MFLAGS) -f makefile.x xconqrast
  121. X
  122. Xmakefile.x : Makefile
  123. X    sed -e '/^###/q' -e '/WHICH/s//x/g' Makefile > makefile.x
  124. X
  125. Xshar.core: conqrast.c 
  126. X    shar -c -v conqrast.c > shar.core
  127. X
  128. Xshar.sun: sunstuff.c sunconqrast.h
  129. X    shar -c -v sunstuff.c sunconqrast.h > shar.sun
  130. X
  131. Xshar.x: xstuff.c xconqrast.h
  132. X    shar -c -v xstuff.c xconqrast.h > shar.x
  133. X
  134. Xshar.general: Makefile README error.c file.c file.h util.c conqrast.man
  135. X    shar -c -v Makefile README conqrast.man error.c file.c file.h util.c > shar.general
  136. X
  137. Xshar: shar.general shar.sun shar.x shar.core
  138. X
  139. Xcheckpoint:
  140. X    cp Makefile README *.[ch] *.man old
  141. X    /bin/rm *.diff newfiles difffiles
  142. X
  143. Xclean:
  144. X    /bin/rm -f *.o *.diff patch shar.* *~ "#*" makefile.* newfiles difffiles
  145. X
  146. Xdiffs:
  147. X    echo -n >patch
  148. X    -for i in old/* ; do \
  149. X        j=`basename $$i` ;\
  150. X        if diff -c $$i $$j > $$j.diff ;\
  151. X            then \
  152. X            /bin/rm $$j.diff ;\
  153. X        else \
  154. X            cat  $$j.diff >> patch ;\
  155. X            wc $$j.diff ;\
  156. X        fi ;\
  157. X    done
  158. X
  159. Xnewfiles:
  160. X    echo -n > newfiles
  161. X    -for i in *.[ch1] ; do\
  162. X        if test -f old/$$i ; then\
  163. X            : ;\
  164. X        else \
  165. X            echo $$i >> newfiles ;\
  166. X        fi ;\
  167. X    done
  168. X
  169. Xdifffiles: newfiles diffs
  170. X    echo -n > difffiles
  171. X    -for i in *.diff ; do\
  172. X        j=`basename $$i .diff` ;\
  173. X        echo -n $$j ;\
  174. X        is=`wc $$i |colrm 9`;\
  175. X        js=`wc $$j |colrm 9`;\
  176. X        echo " " $$js $$is ;\
  177. X        if test $$is -gt $$js ; then \
  178. X            echo is very new! ;\
  179. X            echo $$j >> newfiles ;\
  180. X        else \
  181. X            echo is changed ;\
  182. X            echo $$i >> difffiles ;\
  183. X        fi ;\
  184. X    done
  185. X
  186. Xupdate: newfiles difffiles
  187. X    -n=1;for i in `cat difffiles` `cat newfiles` ; do \
  188. X        lines=`wc $$them $$i| tail -1 | colrm 9` ;\
  189. X        echo $$them $$i $$lines ;\
  190. X        if test $$lines -gt 800 ; then\
  191. X            echo chop! ;\
  192. X            $(SHAR) -c -v $$them > shar.$$n ;\
  193. X            n=`expr $$n + 1` ;\
  194. X            them="$$i" ;\
  195. X        else \
  196. X            them="$$them $$i" ;\
  197. X        fi ;\
  198. X    done ;\
  199. X    $(SHAR) -c -v $$them > shar.$$n
  200. X    /bin/rm newfiles difffiles
  201. X
  202. SHAR_EOF
  203. chmod 0644 Makefile || echo "restore of Makefile fails"
  204. sed 's/^X//' << 'SHAR_EOF' > README &&
  205. X
  206. XThis directory contains the code for conqrast, a program for
  207. Xdisplaying nice maps of conquer games on sun consoles and, sometime in
  208. Xthe future, on X windows displays.
  209. X
  210. XSee the manual page conqrast.1 for more details.
  211. X
  212. XBugs should probably be sent to me, Richard Caley.
  213. X
  214. X    rjc@uk.ac.ed.aipna
  215. X
  216. Xor permutations thereof that your local mailer demands.
  217. X
  218. SHAR_EOF
  219. chmod 0644 README || echo "restore of README fails"
  220. sed 's/^X//' << 'SHAR_EOF' > conqrast.c &&
  221. X#include <stdio.h>
  222. X#include <strings.h>
  223. X#include "../header.h"
  224. X#include "file.h"
  225. X#include HEADERFILE
  226. X
  227. X/*********************************************************************
  228. X*                                                                    *
  229. X* This program draws a map of the conquer world on a bitmap system   *
  230. X*                                                                    *
  231. X* Written by Richard Caley July 1989 and hacked extensively          *
  232. X* thereafter.                                                        *
  233. X*                                                                    *
  234. X* You may copy, distribute, modify or do what you will with this     *
  235. X* code so long as this message remains in it and so long as you do   *
  236. X* not charge for it, nor distribute the program without the source.  *
  237. X*                                                                    *
  238. X* There is a horrid hack for getpass - to make this read the         *
  239. X* password from standard in one has to disconnect from the control   *
  240. X* terminal. GAG! It should be possible to disconnect just the        *
  241. X* conquer from the control terminal . . . someday.                   *
  242. X*                                                                    *
  243. X* See Readme for more details.                                       *
  244. X*                                                                    *
  245. X*********************************************************************/
  246. X
  247. X#define GAP (2)            /* fudge factor - space above
  248. X                 * and below titles */
  249. X
  250. X#define total_height (height*mag+ (do_title?4*GAP+2*font_height(titlefont):0))
  251. X                /* height of map and title bars */
  252. X
  253. X#define yoffset(place) ((place)+(do_title?font_height(titlefont)+GAP+GAP:0))
  254. X                /* a y position */
  255. X
  256. X#define tracef if(trace) printf
  257. X
  258. Xchar *getpass();
  259. Xvoid error(), ioerror();
  260. Xchar *passwd=NULL;
  261. Xchar *nation=NULL;
  262. Xint turn;
  263. Xint trace=0;
  264. Xint bg=0;
  265. Xchar conquer_version[100];
  266. X
  267. X#define conqrast_version "1.0"
  268. X
  269. X#ifndef conqrast_name
  270. X#    define conqrast_name "Some conqrast" /* this is redefined in the header */
  271. X#    define driver_version "unknown driver"
  272. X#endif
  273. X
  274. X#define HEADER_TAG "Conquer Version" /* just before first line of map */
  275. X#define HEADER_TAG_LENGTH (sizeof(HEADER_TAG)/sizeof(char)-1)
  276. X
  277. Xextern struct                /* maps from size of map to the font */
  278. X                /* to use */
  279. X    {                /* if size > mag use font */
  280. X    int mag;
  281. X    char *romanfont,*boldfont;
  282. X    } fonts[];
  283. X
  284. Xstruct                /* Maps from terrain to brightness */
  285. X    {
  286. X    char c;            
  287. X    int val;            /* must be between 0 and 255 */
  288. X    } values[] =
  289. X        {
  290. X    ' ', 256,
  291. X    '~', 0,
  292. X    '-', 64,
  293. X    '%', 128,
  294. X    '^', 192,
  295. X    '#', 224,
  296. X    '\0'
  297. X        };
  298. X
  299. Xchar *mapnames[] =
  300. X    {
  301. X    "This should never happen",
  302. X    "Altitude",
  303. X    "Vegetation",
  304. X    "Nation",
  305. X    "Designation"
  306. X    };
  307. X
  308. X#define num_mapnames (sizeof(mapnames)/sizeof(char *))
  309. X
  310. X/*********************************************************************
  311. X*                                                                    *
  312. X* Font mapping information. Fonts used by the system have symbolic   *
  313. X* names so they can be referred to on the commend line. font_table   *
  314. X* records which fonts go with which name.                            *
  315. X*                                                                    *
  316. X*********************************************************************/
  317. X
  318. Xenum mapfont
  319. X    {
  320. X    f_nation,
  321. X    f_designation,
  322. X    f_title,
  323. X    f_last
  324. X    };
  325. X
  326. Xstruct 
  327. X    {
  328. X    char *name;
  329. X    font romanfont;
  330. X    font boldfont;
  331. X    } font_table[(unsigned)f_last+1] =
  332. X    {
  333. X    {"nation"},
  334. X    {"designation"},
  335. X    {"title"},
  336. X    {NULL}
  337. X    };
  338. X
  339. X#define MAXDITHER 4        /* don't touch this */
  340. X
  341. Xshort dit[1<<MAXDITHER][1<<MAXDITHER];
  342. X
  343. X/*********************************************************************
  344. X*                                                                    *
  345. X* Sets the default fonts for the given size. If the font has already *
  346. X* been specified ( ie is non-null ) leaves it alone.                 *
  347. X*                                                                    *
  348. X*********************************************************************/
  349. X
  350. Xvoid
  351. Xset_default_fonts(mag,f)
  352. X
  353. Xint mag;
  354. Xenum mapfont f;
  355. X
  356. X{
  357. X    int i;
  358. X
  359. X    if (font_table[(unsigned)f].romanfont==NULL) /* if there was no font specified */
  360. X    {
  361. X    for(i=0;;i++)
  362. X        {            /* find one */
  363. X        if (fonts[i].mag >= mag )
  364. X        break;
  365. X        else if (fonts[i].mag < mag )
  366. X        {
  367. X        if(bad_font(font_table[(unsigned)f].romanfont=
  368. X                font_named(fonts[i].romanfont)))
  369. X            error("Can't get font '%s' as %s font",
  370. X              fonts[i].romanfont,font_table[(unsigned)f].name);
  371. X        if ( font_table[(unsigned)f].boldfont==NULL && fonts[i].boldfont !=NULL)
  372. X            if (bad_font(font_table[(unsigned)f].boldfont=
  373. X                 font_named(fonts[i].boldfont)))
  374. X            error("Can't get font '%s' as bold %s font",
  375. X                  fonts[i].romanfont,font_table[(unsigned)f].name);
  376. X        }
  377. X        }
  378. X    if(font_table[(unsigned)f].romanfont==NULL)
  379. X        error("No font small enough for size %d %s",mag,font_table[(unsigned)f].name);
  380. X    }
  381. X    
  382. X    }
  383. X
  384. X/*********************************************************************
  385. X*                                                                    *
  386. X* Set up a single font. if the name is in the table ( or is a prefix *
  387. X* ) then insert the name into the font table. If the name begins     *
  388. X* with 'b' then sets the bold font.                                  *
  389. X*                                                                    *
  390. X*********************************************************************/
  391. X
  392. Xvoid
  393. Xset_a_font(name,fontname)
  394. X
  395. Xchar *name;
  396. Xchar *fontname;
  397. X
  398. X{
  399. X    int i,bold=0,l;
  400. X    font thefont;
  401. X
  402. X    if( name[0]=='b')
  403. X    {
  404. X    name++;
  405. X    bold=1;
  406. X    }
  407. X
  408. X    l=strlen(name);
  409. X
  410. X    for (i=0;i< (int)f_last;i++)
  411. X    if (!strncmp(name,font_table[i].name,l))
  412. X        break;
  413. X
  414. X    if ( i == (int)f_last)
  415. X    error("Unknown font name '%s'",name);
  416. X
  417. X    thefont=font_named(fontname);
  418. X
  419. X    if ( bad_font(thefont) )
  420. X    error("Can't get font '%s'",fontname);
  421. X
  422. X    if (bold)
  423. X    font_table[i].boldfont=thefont;
  424. X    else
  425. X    font_table[i].romanfont=thefont;
  426. X    }
  427. X
  428. X/*********************************************************************
  429. X*                                                                    *
  430. X* scan over the header of the map. Returns the number of the map, or *
  431. X* 0 if the map is bad. If `pipe' is != 0 then the input is a pipe    *
  432. X* and an eof implies a bad password.                                 *
  433. X*                                                                    *
  434. X* Tries to cope with DEBUG and none-DEBUG conquers                   *
  435. X*                                                                    *
  436. X*********************************************************************/
  437. X
  438. Xscan_header(f,pipe)
  439. X
  440. XFILE *f;
  441. Xint pipe;
  442. X
  443. X{
  444. X    char line[1024];
  445. X    char which[100];
  446. X    static char who[100];
  447. X    int mapid;
  448. X
  449. X    while ( fgets(line,1024,f) != NULL)    /* scan to top of map */
  450. X    {
  451. X    if (!strncmp(line,HEADER_TAG,HEADER_TAG_LENGTH))
  452. X        break;
  453. X    }
  454. X
  455. X    if (feof(f))
  456. X    {
  457. X    if(pipe)
  458. X        error("Password incorrect");
  459. X    else
  460. X        error("Unexpected end of map file");
  461. X    }
  462. X
  463. X    if (sscanf(line,"Conquer Version %[0-9.] : %s Map %*s %*s %s on Turn %d",conquer_version,which,who,&turn)!=4)
  464. X    error("Bad title line (wrong version?) '%s'",line);
  465. X
  466. X    for(mapid=1;mapid < num_mapnames;mapid++)
  467. X    if(!strcmp(mapnames[mapid],which))
  468. X        break;
  469. X
  470. X    if ( mapid==num_mapnames)
  471. X    mapid= 0;
  472. X    else if ( trace && !pipe)
  473. X    printf("Found %s map\n", which);
  474. X
  475. X    if(!strcmp(who,"World"))
  476. X    nation="god";
  477. X    else
  478. X    nation=who;
  479. X
  480. X    tracef("Nation is %s\n",nation);
  481. X
  482. X    return mapid;
  483. X    }
  484. X
  485. X/*********************************************************************
  486. X*                                                                    *
  487. X* Find maps in a file and store away a file pointer and offset for   *
  488. X* each                                                               *
  489. X*                                                                    *
  490. X*********************************************************************/
  491. X
  492. Xvoid
  493. Xprocess_map_file(name)
  494. X
  495. Xchar *name;
  496. X
  497. X{
  498. X    int which;
  499. X    FILE *f;
  500. X    char line[1024];
  501. X
  502. X    tracef("Searching file %s\n",name);
  503. X
  504. X    if ((f=fopen(name,"r"))==NULL)
  505. X    ioerror("Can't open map file '%s'",name);
  506. X
  507. X    while(1)
  508. X    {
  509. X    long top;
  510. X
  511. X    which=scan_header(f,0);
  512. X    
  513. X    if(which==0)
  514. X        error("Bad map file '%s'",name);
  515. X
  516. X    myopen(which,f);
  517. X    top=ftell(f);
  518. X    while(fgets(line,1024,f)!=NULL)
  519. X        {
  520. X        if (!strncmp(line,HEADER_TAG,HEADER_TAG_LENGTH))
  521. X        break;
  522. X        top=ftell(f);
  523. X        }
  524. X
  525. X    if(feof(f))
  526. X        break;
  527. X
  528. X    fseek(f,top,0);
  529. X    }
  530. X    }
  531. X
  532. X/*********************************************************************
  533. X*                                                                    *
  534. X* Get a map. If the map was not in one of the files on the command   *
  535. X* line it runs conquer -p to get it.                                 *
  536. X*                                                                    *
  537. X*     Which selects the map.                                         *
  538. X*     Args are passed to conqrun.                                    *
  539. X*     Tmpname is the name of a temporary file to use. This is        *
  540. X*         deleted in this routine so you can reuse the name.         *
  541. X*                                                                    *
  542. X*     All except `which' are ignored if the user has given a map     *
  543. X*     file of the correct type as an argumant.                       *
  544. X*                                                                    *
  545. X*********************************************************************/
  546. X
  547. Xint
  548. Xget_map_file(which,args,tmpname)
  549. X
  550. Xint which;
  551. Xchar *args;
  552. Xchar *tmpname;
  553. X
  554. X{
  555. X    char command[100];
  556. X    FILE *tmp;
  557. X
  558. X    if ( ! myisopen(which))
  559. X    {
  560. X    if (nation==NULL)
  561. X        {
  562. X        tracef("Assuming god\n");
  563. X
  564. X        nation="god";
  565. X        }
  566. X
  567. X    tracef("Asking conquer for %s map\n",mapnames[which]);
  568. X
  569. X    if (passwd==NULL)
  570. X        {
  571. X        passwd=getpass("Enter conquer password: ");
  572. X        }
  573. X
  574. X    tracef("Disconnecting ( HACK! ) bye bye\n");
  575. X
  576. X    disconnect();        /* disconnect from controling tty */
  577. X                            /* ( hack for getpass ) */
  578. X
  579. X    if (bg)            /* go into background if asked */
  580. X        {
  581. X        tracef("Going into background\n");
  582. X
  583. X        background();
  584. X        }
  585. X
  586. X    sprintf(command,"conquer -p %s > %s 2>/dev/null",args,tmpname);
  587. X    
  588. X    if((tmp=popen(command,"w"))==NULL)
  589. X        ioerror("can't run conquer");
  590. X    
  591. X    if (fprintf(tmp,"%s\n%s\n%c\n",nation,passwd, which+'0')==EOF)
  592. X        error("Couldn't get map. Conquer may be updating.\n");
  593. X    
  594. X    pclose(tmp);
  595. X    
  596. X    if((tmp=fopen(tmpname,"r"))==NULL)
  597. X        ioerror("can't open %s",tmpname);
  598. X    
  599. X    unlink(tmpname);        /* delete it */
  600. X
  601. X    (void)scan_header(tmp,1);
  602. X    myopen(which,tmp);
  603. X    }
  604. X
  605. X    return which;
  606. X    }
  607. X
  608. X/*ARGSUSED*/
  609. Xmain(argc,argv)
  610. X
  611. Xint argc;
  612. Xchar *argv[];
  613. X
  614. X{
  615. X    char line[1024];
  616. X    char desline[1024];
  617. X    char tmpname[20];
  618. X    char args[100];
  619. X    char *screen_name=get_default_screen_name();
  620. X    screen_type screen=NULL;
  621. X    int  mapfile;
  622. X    int destmapfile;
  623. X    int mag=11;
  624. X    bitmap pr;
  625. X    int width,height;
  626. X    extern char *myname;
  627. X    int x,y,i,j,val;
  628. X    char c;
  629. X    char *mapname=NULL;
  630. X    char *world=NULL;
  631. X    int do_nations=0,barbarians=0,markbarbs=0;
  632. X    int all=0,live=0,altitude=1;
  633. X    int desig=0;
  634. X    int do_title=1;
  635. X    font titlefont;
  636. X    int boldtitle=0;        /* indicates that the title font should be
  637. X                   emboldened - ie `titlefont' is roman and
  638. X                   so _we_ must do the bold */
  639. X
  640. X
  641. X    myname=argv[0];
  642. X
  643. X    strcpy(args,"");
  644. X
  645. X    while(*(++argv)!=NULL)
  646. X    if (!strncmp(*argv,"-o",2))
  647. X        {
  648. X        mapname= *(++argv);
  649. X        if ( is_screenname(mapname))
  650. X        {
  651. X        screen_name=mapname;
  652. X        mapname=NULL;
  653. X        }
  654. X        }
  655. X    else if (!strcmp(*argv,"-l"))
  656. X        live++;
  657. X    else if (!strcmp(*argv,"-D"))
  658. X        sprintf(args,"%s -d %s",args,world= *(++argv));
  659. X    else if (!strcmp(*argv,"-N"))
  660. X        nation= *(++argv);
  661. X    else if (!strcmp(*argv,"-bg"))
  662. X        bg++;
  663. X    else if (!strcmp(*argv,"-a"))
  664. X        altitude=0;
  665. X    else if (!strcmp(*argv,"-f"))
  666. X        {
  667. X        char *which= *(++argv), *fontname= *(++argv);
  668. X        set_a_font(which,fontname);
  669. X        }
  670. X    else if (!strncmp(*argv,"-b",2))
  671. X        {
  672. X        barbarians++;
  673. X        if ( (*argv)[2]=='a')
  674. X        markbarbs++;
  675. X        }
  676. X    else if (!strcmp(*argv,"-m"))
  677. X        mag=atoi(*(++argv));
  678. X    else if (!strncmp(*argv,"-c",2))
  679. X        {
  680. X        c=(*argv)[2];
  681. X        for (i=0;;i++)
  682. X        {
  683. X        if (values[i].c =='\0')
  684. X            error("Unknown contour '%c'",c);
  685. X        else if ( values[i].c == c)
  686. X            {
  687. X            values[i].val=atoi(*(++argv));
  688. X            break;
  689. X            }
  690. X        }
  691. X        }
  692. X    else if (!strncmp(*argv,"-n",2))
  693. X        {
  694. X        do_nations++;
  695. X        if ( (*argv)[2]=='a')
  696. X        ++all;
  697. X        }
  698. X    else if (!strncmp(*argv,"-d",2))
  699. X        {
  700. X        desig++;
  701. X        }
  702. X    else if (!strcmp(*argv,"-h"))
  703. X        help_message(myname);
  704. X    else if (!strcmp(*argv,"-t"))
  705. X        do_title=0;
  706. X    else if (!strcmp(*argv,"-v"))
  707. X        trace++;
  708. X    else if ( (*argv)[0]=='-')
  709. X        {
  710. X        printf("Unknown option '%s'\n",*argv);
  711. X        help_message(myname);
  712. X        }
  713. X        else
  714. X        process_map_file(*argv);
  715. X
  716. X    if (do_nations)        /* if we have to put in nations */
  717. X    set_default_fonts(mag,f_nation);
  718. X
  719. X    if (desig)
  720. X    {
  721. X    if (all)
  722. X        error("Only one of -d and -na allowed!");
  723. X
  724. X    set_default_fonts(mag,f_designation);
  725. X    }
  726. X
  727. X    if (do_title)
  728. X    {
  729. X    set_default_fonts(mag+2,f_title);
  730. X    if ( (titlefont=font_table[(unsigned)f_title].boldfont)==NULL)
  731. X        {
  732. X        boldtitle=1;
  733. X        titlefont=font_table[(unsigned)f_title].romanfont;
  734. X        }
  735. X
  736. X    }
  737. X
  738. X    screen=screen_named(screen_name);
  739. X
  740. X    sprintf(tmpname,"/tmp/conq%d",getpid());
  741. X
  742. X    mapfile=get_map_file(altitude?1:3, /* get a map */
  743. X             args,tmpname);
  744. X
  745. X    if(mygets(line,1024,mapfile)==NULL)
  746. X    error("empty map!");
  747. X
  748. X    width=strlen(line)-1;    /* count height and width */
  749. X
  750. X    for(height=1;mygets(line,1024,mapfile)!=NULL;height++)
  751. X    if(!strncmp(line,HEADER_TAG,HEADER_TAG_LENGTH)||
  752. X       !strncmp(line,"reading",7))
  753. X        break;
  754. X
  755. X    tracef("Size %d X %d, image %d X %d\n",width,height,width*mag,height*mag);
  756. X
  757. X    initialise_bitmaps();
  758. X
  759. X    if(live)            /* if live do it on the screen */
  760. X    {
  761. X    if ((pr=get_screen_bitmap(screen))==NULL)
  762. X        ioerror("Can't open screen %s",screen_name);
  763. X    }
  764. X    else            /* otherwise in memory */
  765. X    pr=create_bitmap(width*mag,total_height);
  766. X
  767. X    myrewind(mapfile);
  768. X
  769. X    if (altitude)        /* if needed do altitude */
  770. X    {
  771. X    int xx,yy;
  772. X    tracef("Drawing topography\n");
  773. X
  774. X    build_dither_matrix(MAXDITHER);
  775. X
  776. X    yy=yoffset(0);
  777. X    for(y=0;y<height;y++,yy+=mag)
  778. X        {
  779. X        if (mygets(line,1024,mapfile)==NULL)
  780. X        error("unexpected end of file!");
  781. X    
  782. X        for(xx=x=0;x<width;x++,xx+=mag)
  783. X        {
  784. X        val= -1;
  785. X        for(i=0;values[i].c!='\0';i++)
  786. X            if ( values[i].c==line[x] )
  787. X            val=values[i].val;
  788. X        
  789. X        if ( val<0 )
  790. X            {        /* non fatal, I like it that way */
  791. X            printf("unknown character %c\n",line[x]);
  792. X            continue;
  793. X            }
  794. X        
  795. X        for(i=0;i<mag;i++)
  796. X            for(j=0;j<mag;j++)
  797. X            {
  798. X            set_bit(pr,xx+i,yy+j,dit[(xx+i)%16][(yy+j)%16] >=val?1:0);
  799. X            }
  800. X        }
  801. X        }
  802. X    
  803. X    myclose(mapfile);
  804. X    }
  805. X
  806. X    if(do_nations||desig)    /* nations */
  807. X    {
  808. X    font nf, bnf;
  809. X    font df;
  810. X    int xx,yy;
  811. X    char des,
  812. X    current='\0';        /* keeps track of which nation we are in */
  813. X    char last[1024];    /* ditto vertically for each column */
  814. X
  815. X    tracef("Drawing nations\n");
  816. X
  817. X    if (do_nations)
  818. X        {
  819. X        nf = font_table[(unsigned)f_nation].romanfont;
  820. X        bnf = font_table[(unsigned)f_nation].boldfont;
  821. X        }
  822. X
  823. X    if (desig)
  824. X        {
  825. X        df = font_table[(unsigned)f_designation].romanfont;
  826. X        }
  827. X
  828. X    if (altitude)        /* if no altitude this was gotten to */
  829. X        /* count the size */
  830. X        mapfile=get_map_file(3,args,tmpname);
  831. X
  832. X    destmapfile=get_map_file(4,args,tmpname);
  833. X
  834. X    yy=yoffset(mag);
  835. X    for(y=0;y<height;y++,yy+=mag)
  836. X        {
  837. X        if(mygets(line,1024,mapfile)==NULL)
  838. X        error("unexpected end of file in nation map");
  839. X        if(mygets(desline,1024,destmapfile)==NULL)
  840. X        error("unexpected end of file in designation map");
  841. X
  842. X        current='\0';           
  843. X        for(x=0;x<width;x++)
  844. X        {
  845. X        c=line[x];
  846. X        des=desline[x];
  847. X
  848. X        if (index("~-%#^",c)!=NULL) /* if no-one owns */
  849. X            c=' ';
  850. X        else if ( !barbarians && c == '*' ) /* if barbarian or lizard */
  851. X            c=' ';
  852. X
  853. X        xx=x*mag;
  854. X        
  855. X        if (do_nations && c !=current )    /* crossing a vertical border */
  856. X            {
  857. X            draw_line(pr,xx-1,yy,xx-1,yy-mag,BLACK);
  858. X            draw_line(pr,xx,yy,xx,yy-mag,WHITE);
  859. X            draw_line(pr,xx+1,yy,xx+1,yy-mag,BLACK);
  860. X            current=c;
  861. X            }
  862. X
  863. X        if ( do_nations & last[x] != c)    /* horizontal border above */
  864. X            {
  865. X            draw_line(pr,xx,yy-mag,xx+mag,yy-mag,WHITE);
  866. X            draw_line(pr,xx,yy-mag+1,xx+mag,yy-mag+1,BLACK);
  867. X            draw_line(pr,xx,yy-mag-1,xx+mag,yy-mag-1,BLACK);
  868. X            last[x]=c;
  869. X            }
  870. X        
  871. X        /*
  872. X         * The following is convoluted to get the right things bold
  873. X         * I think it copes with all cases 
  874. X         */
  875. X
  876. X        if ( do_nations && des == 'C' )
  877. X            {
  878. X            if (all||desig)
  879. X            {
  880. X            if (bnf)
  881. X                put_txt(pr,xx,yy,bnf,c,0);
  882. X            else
  883. X                put_txt(pr,xx,yy,nf,c,1);
  884. X            }
  885. X            else
  886. X            put_txt(pr,xx,yy,nf,c,0);
  887. X            }
  888. X        else if (do_nations && all && c != ' ' && ( c != '*' || markbarbs ) )
  889. X            put_txt(pr,xx,yy,nf,c,0);
  890. X        else if (desig && des != '-')
  891. X            put_txt(pr,xx,yy,df,des,0);
  892. X        }
  893. X        }
  894. X        
  895. X        
  896. X    myclose(mapfile);
  897. X    myclose(destmapfile);
  898. X    }
  899. X
  900. X                /* line down right */
  901. X    draw_line(pr,mag*width-1,yoffset(0),mag*width-1,yoffset(mag*height),BLACK);
  902. X    draw_line(pr,mag*width-2,yoffset(0),mag*width-2,yoffset(mag*height),WHITE);
  903. X    draw_line(pr,mag*width-3,yoffset(0),mag*width-3,yoffset(mag*height),BLACK);
  904. X                /* left */
  905. X    draw_line(pr,0,yoffset(0),0,yoffset(mag*height),BLACK);
  906. X    draw_line(pr,1,yoffset(0),1,yoffset(mag*height),WHITE);
  907. X    draw_line(pr,2,yoffset(0),2,yoffset(mag*height),BLACK);
  908. X                /* top */
  909. X    draw_line(pr,0,yoffset(0),mag*width,yoffset(0),BLACK);
  910. X    draw_line(pr,0,yoffset(1),mag*width,yoffset(1),WHITE);
  911. X    draw_line(pr,0,yoffset(2),mag*width,yoffset(2),BLACK);
  912. X                /* bottom */
  913. X    draw_line(pr,0,yoffset(mag*height-1),mag*width,yoffset(mag*height-1),BLACK);
  914. X    draw_line(pr,0,yoffset(mag*height-2),mag*width,yoffset(mag*height-2),WHITE);
  915. X    draw_line(pr,0,yoffset(mag*height-3),mag*width,yoffset(mag*height-3),BLACK);
  916. X
  917. X    if (do_title)
  918. X    {
  919. X    sprintf(line,"Conquer Version %s",conquer_version);
  920. X    put_txt(pr,mag,
  921. X        font_baseline(titlefont)+GAP+1,titlefont,'\0',boldtitle,line);
  922. X
  923. X    sprintf(line,"%s Version %s/%s",conqrast_name,conqrast_version,driver_version);
  924. X    put_txt(pr,width*mag-strlen(line)*font_width(titlefont)-GAP-GAP,
  925. X        font_baseline(titlefont)+GAP+1,titlefont,'\0',boldtitle,line);
  926. X
  927. X    if ( nation==NULL || !strcmp(nation,"god"))
  928. X        sprintf(line,"Conquer World Map For Turn %d",turn);
  929. X    else
  930. X        sprintf(line,"Conquer Map For Nation %s On Turn %d",nation,turn);
  931. X
  932. X    put_txt(pr,(width*mag-strlen(line)*font_width(titlefont))/2,
  933. X        height*mag+GAP+font_height(titlefont)+GAP+
  934. X        GAP+font_baseline(titlefont),titlefont,'\0',boldtitle,line);
  935. X    }
  936. X
  937. X    if (mapname !=NULL)        /* told to save in file */
  938. X    {
  939. X    write_bitmap(pr,mapname,width*mag,total_height);
  940. X    destroy_bitmap(pr);
  941. X    }
  942. X    else if (!live)        /* not drawn already */
  943. X    {
  944. X    display_bitmap(pr,0,0,width*mag,total_height);
  945. X    destroy_bitmap(pr);
  946. X    }
  947. X    else
  948. X    destroy_bitmap(pr);
  949. X
  950. X    finish_bitmaps();
  951. X
  952. X    tracef("done\n");
  953. X
  954. X    }
  955. X
  956. X/*********************************************************************
  957. X*                                                                    *
  958. X* put the character c at (xx, yy) in pr, using font pf. Highlight    *
  959. X* means bold ( not very good at the moment, anyone want to improve   *
  960. X* it? ).                                                             *
  961. X*                                                                    *
  962. X* This works by first blacking out an area around the character and  *
  963. X* then printing the character.                                       *
  964. X*                                                                    *
  965. X* Bolding is done by smearing ( yeuch ).                             *
  966. X*                                                                    *
  967. X* If c is the null character then str is a string to display in the  *
  968. X* same way.                                                          *
  969. X*                                                                    *
  970. X*********************************************************************/
  971. X/*VARARGS6*/
  972. Xput_txt(pr,xx,yy,pf,c,highlight,str)
  973. X
  974. Xbitmap pr;
  975. Xint xx,yy;
  976. Xfont pf;
  977. Xchar c;
  978. Xint highlight;
  979. Xchar *str;
  980. X
  981. X{
  982. X    int i,j,size;
  983. X    static char st[2];
  984. X    int x,y;
  985. X
  986. X    if ( c !='\0' )
  987. X    {
  988. X    st[0]=c;
  989. X    st[1]='\0';
  990. X    str=st;
  991. X    }
  992. X
  993. X    if (highlight)
  994. X    size=1;
  995. X    else
  996. X    size=0;
  997. X
  998. X    xx+= 2;
  999. X    yy-= 2;
  1000. X
  1001. X    for(i=0,x=xx-1; i<3+size; i++,x++)
  1002. X    for(j=0,y=yy+1; j<3+size; j++,y--)
  1003. X        bitmap_text(pr,x,y,DRAW_BLACK,pf,str);
  1004. X
  1005. X
  1006. X    for(i=0,x=xx;i<1+size;i++,x++)
  1007. X    for(j=0,y=yy;j<1+size;j++,y--)
  1008. X        bitmap_text(pr,x,y,DRAW_WHITE,pf,str);
  1009. X
  1010. X    }
  1011. X
  1012. SHAR_EOF
  1013. chmod 0644 conqrast.c || echo "restore of conqrast.c fails"
  1014. sed 's/^X//' << 'SHAR_EOF' > conqrast.man &&
  1015. X.TH CONQRAST 1 "17th August 1989" "CONQUER"
  1016. X.SH NAME
  1017. Xconqrast \- Displaying and saving maps for conquer
  1018. X.SH SYNOPSIS
  1019. X.B sunconqrast
  1020. X[argumants] [mapfile]...
  1021. X.br
  1022. X.B xconqrast
  1023. X[arguments] [mapfile]...
  1024. X.SH NOTE
  1025. X.I
  1026. Xxconqrast does not work yet. If you want it, do it . . .
  1027. X.SH DESCRIPTION
  1028. X.I Conqrast
  1029. Xis a program which sits on top of conquer and displays maps on bitmap
  1030. Xdevices. Two versions exist at the moment
  1031. X.I sunconqrast
  1032. Xdisplay on a sun workstation screen and saves in sun rasterfile
  1033. Xformat;
  1034. X.I xconqrast
  1035. Xdisplays in the root window of and X Windows display and stores in X
  1036. Xbitmap format.
  1037. X.PP
  1038. XThe map which is drawn is either supplied as a command line argument
  1039. Xor is obtained by running conquer. In the latter case, the nation and
  1040. Xgame are supplied with the \fB-N\fR and \fB-D\fR arguments described
  1041. Xbelow, the nation name will be taken from any map files supplied or,
  1042. Xby default, is "god".
  1043. X.SH OPTIONS
  1044. XArguments are as follows
  1045. X.IP "\fB-o\fR \fIfilename\fR"
  1046. XSave the resulting image in \fIfilename\fR rather than
  1047. Xdisplaying it on the screen.
  1048. X
  1049. X.IP "\fB-o\fR \fIdisplay\fR"
  1050. XUse the display \fIdisplay\fR rather than the default.
  1051. X\fISunconqrast\fR defaults to "/def/fb" and recognised
  1052. Xscreen names by the leading "/dev/" while
  1053. Xxconqrast defaults to "unix:0" and recognises screeen
  1054. Xnames by the colon. This will probaby be needed if you are
  1055. Xrunning on a system with multiple screens etc.
  1056. X
  1057. X.IP "\fB-l\fR"  
  1058. XProduce the image "live". That is on the screen as it
  1059. Xis built rather than in memory. Unsafe since you can
  1060. Xcorrupt the image as as it is drawn, but prety.
  1061. X
  1062. X.IP "\fB-D\fR \fIdir\fR"
  1063. XUse the conquer game in directory \fIdir\fR.
  1064. X
  1065. X.IP "\fB-N\fR \fIname\fR"
  1066. XMake map for nation \fInation\fR.
  1067. X
  1068. X.IP "\fB-m\fR \fInumber\fR"
  1069. XMagnify the image \fInumber\fR times. The default
  1070. Xmagnification is 11.
  1071. X
  1072. X.IP"\fB-n\fR" 
  1073. XDraw in the national boundries and label the capitals
  1074. Xwith the symbol of the nation.
  1075. X
  1076. X.IP "\fB-na\fR"
  1077. XDraw in national boundries and label _all_ the sectors
  1078. Xwith who owns them. This is useful for when a game has
  1079. Xbeen going a while and the nations do not form nice
  1080. Xconnected regions, so isolated fragments of nations
  1081. Xare hard to identify. Capitals are identified by being
  1082. Xlabeled in bold. 
  1083. X
  1084. X.IP "\fB-d\fR"
  1085. XDisplay the designations of sectors. This can be
  1086. Xcombined with -n to draw in the nation boundries and
  1087. Xlabel the capitals with the nations character. In this
  1088. Xcase the capital is displayed bold to distinguish, for
  1089. Xexample, nation 'f's capital from a farm.
  1090. X
  1091. X.IP "\fB-b\fR"
  1092. XDraw in the boundries of barbarian ( ie savages,
  1093. Xnomad, lizard, or pirate ) owned lands. Only
  1094. Xuseful when used with -n or -na.
  1095. X
  1096. X.IP "\fB-ba\fR" 
  1097. XLike \fB-b\fR but labels the barbarian lands with stars.
  1098. X
  1099. X.IP "\fB-a\fR"  
  1100. XDo \fInot\fR draw in the altitudes. This is not useful for
  1101. Xactually drawing nice maps, but since drawing in
  1102. Xaltitude information is slow, it speeds up
  1103. Xexperimentation with different fonts for the nation
  1104. Xlabels. 
  1105. X
  1106. X.IP "\fB-c\fIc\fR \fInumber\fR"
  1107. XDraw altitudes of type \fIc\fR with brightness \fInumber\fR.
  1108. X\fIc\fR is one of "~-%#^" as used by conquer. \fInumber\fR is
  1109. Xbetween 0 and 256 with 0 being black and 256 white.
  1110. X
  1111. X.IP "\fB-t\fR"  
  1112. XDo not title the map. This is necesary when there is
  1113. Xno font small enough.
  1114. X
  1115. X.IP "\fB-f\fR \fItype\fR \fIfont\fR"
  1116. XUse font \fIfont\fR for things of type \fItype\fR.
  1117. XPossible types are
  1118. X.RS
  1119. X.IP "title"     
  1120. XFor the title.
  1121. X.IP "nation"    
  1122. XFor the nation/capital labels.
  1123. X.IP "designation" 
  1124. XFor the designations.
  1125. X.RE
  1126. Xor any of the above with `b' prepended ( eg. "btitle"
  1127. X) to set the bold version. If no fonts are specified,
  1128. Xconqrast will choose for you.
  1129. X
  1130. X.IP "\fB-v\fR"  
  1131. XPrint out notes on what is being done. 
  1132. X.PP
  1133. XThe \fImapfiles\fR should be as produced by 
  1134. X.IP
  1135. Xconquer -p > mapfile'
  1136. X.PP
  1137. XIf you do not supply a mapfile which is needed to produce the map you
  1138. Xrequest ( altitude unless `\fB-a\fR'; nation and designation for `-n';
  1139. Xdesignation for `\fB-d\fR' ) \fIconqrast\fR will prompt you for the nation's
  1140. Xpassword and attempt to run 
  1141. X.IP
  1142. Xconquer -p -n\fIname\fR
  1143. X.PP
  1144. Xto get the map it wants.
  1145. X
  1146. XMore than one map may be put into a single file as shown in the example below. 
  1147. X
  1148. X.SH EXAMPLE
  1149. X.IP
  1150. X.br
  1151. X% \fBconquer -p -nTolland >mapfile\fR
  1152. X.br
  1153. Xconquer Version 4.4: Copyright (c) 1988 by Edward M Barlow
  1154. X.br
  1155. X
  1156. X.br
  1157. XWhat is your Nation's Password: 
  1158. X.br
  1159. X
  1160. X.br
  1161. XFor convenience, this output is to stderr,
  1162. X.br
  1163. Xwhile the maps will be sent to stdout.
  1164. X.br
  1165. X
  1166. X.br
  1167. XThe valid options are,
  1168. X.br
  1169. X1) altitudes
  1170. X.br
  1171. X2) vegetations
  1172. X.br
  1173. X3) nations
  1174. X.br
  1175. X4) designations
  1176. X.br
  1177. X
  1178. X.br
  1179. XWhat type of map? \fB1\fR
  1180. X.br
  1181. X
  1182. X.br
  1183. Xdoing print of altitude
  1184. X.br
  1185. X% \fBconquer -p -nTolland >> mapfile\fR
  1186. X.br
  1187. Xconquer Version 4.4: Copyright (c) 1988 by Edward M Barlow
  1188. X.br
  1189. X
  1190. X.br
  1191. XWhat is your Nation's Password: 
  1192. X.br
  1193. X
  1194. X.br
  1195. XFor convenience, this output is to stderr,
  1196. X.br
  1197. Xwhile the maps will be sent to stdout.
  1198. X.br
  1199. X
  1200. X.br
  1201. XThe valid options are,
  1202. X.br
  1203. X1) altitudes
  1204. X.br
  1205. X2) vegetations
  1206. X.br
  1207. X3) nations
  1208. X.br
  1209. X4) designations
  1210. X.br
  1211. X
  1212. X.br
  1213. XWhat type of map? \fB3\fR
  1214. X.br
  1215. X
  1216. X.br
  1217. Xdoing print of nations
  1218. X.br
  1219. X% \fBsunconqrast -n -m 11 mapfile\fR
  1220. X.br
  1221. XEnter conquer password: 
  1222. X.br
  1223. X
  1224. Xnotice how it prompts for your password when it
  1225. Xfinds it needs the designation map which was not given in the file.
  1226. X
  1227. X.SH PROBLEMS
  1228. X
  1229. X.I
  1230. Xxconqrast
  1231. Xdoes not work yet! not even slightly. Don't even think of it.
  1232. X
  1233. XThe method used to produce bold when there is no bold font is
  1234. Xrather poor.
  1235. X
  1236. Xno fonts for small maps ( < mag 9 ) on my machine so that is
  1237. Xthe minimum. If you want a smaller one have a look in
  1238. X/usr/lib/fonts/fixedwidthfonts on your machine or create your
  1239. Xown. In the latter case, you could send it to me too . . .
  1240. X
  1241. XThe way -o works makes it impossible to draw live on a
  1242. Xnon-standard screen then dump to a file. Doesn't seem to be
  1243. Xlikely to cause anyone too many problems ( famous last words!
  1244. X).
  1245. X
  1246. X
  1247. X.SH "THINGS TO DO"
  1248. X
  1249. Xcreate a set nice fonts ( different sizes ) for designations
  1250. Xso that they can be represented by a symbol rather than by a
  1251. Xletter. 
  1252. X
  1253. Xdisconnect the conquer process from the terminal rathert then
  1254. Xsunconqrast.
  1255. X
  1256. Xbetter help message.
  1257. X
  1258. X.SH SEE ALSO
  1259. Xconquer(6) rasterfile(5) screenload(1) bitmap(1x)
  1260. X.SH AUTHER
  1261. XRichard Caley
  1262. SHAR_EOF
  1263. chmod 0644 conqrast.man || echo "restore of conqrast.man fails"
  1264. sed 's/^X//' << 'SHAR_EOF' > error.c &&
  1265. X#include <stdio.h>
  1266. X
  1267. Xint errno;
  1268. Xchar *sys_errlist[];
  1269. X
  1270. Xchar *myname="Someone";
  1271. X
  1272. X/*VARARGS1*/
  1273. Xvoid
  1274. Xioerror(str,arg1,arg2,arg3)
  1275. X
  1276. Xchar *str;
  1277. Xint arg1, arg2, arg3;
  1278. X
  1279. X{
  1280. Xfprintf(stderr,"%s: ",myname);
  1281. Xfprintf(stderr,str,arg1,arg2,arg3);
  1282. Xfprintf(stderr," - %s\n",sys_errlist[errno]);
  1283. Xexit(1);
  1284. X}
  1285. X
  1286. X/*VARARGS1*/
  1287. Xvoid
  1288. Xerror(str,arg1,arg2,arg3)
  1289. X
  1290. Xchar *str;
  1291. Xint arg1, arg2, arg3;
  1292. X
  1293. X{
  1294. Xfprintf(stderr,"%s: ",myname);
  1295. Xfprintf(stderr,str,arg1,arg2,arg3);
  1296. Xfputc('\n',stderr);
  1297. Xexit(1);
  1298. X}
  1299. X
  1300. SHAR_EOF
  1301. chmod 0644 error.c || echo "restore of error.c fails"
  1302. sed 's/^X//' << 'SHAR_EOF' > file.c &&
  1303. X#include <stdio.h>
  1304. X#include "file.h"
  1305. X
  1306. X/*********************************************************************
  1307. X*                                                                    *
  1308. X* All the my* routines mimic stdio routines but manipulate struct    *
  1309. X* file's The point is that we can read from and otherwise manipulate *
  1310. X* more than one place in a file ( for more than one map ).           *
  1311. X*                                                                    *
  1312. X*********************************************************************/
  1313. X
  1314. X/*********************************************************************
  1315. X*                                                                    *
  1316. X* struct file's play the roll of FILE *'s                            *
  1317. X*                                                                    *
  1318. X*********************************************************************/
  1319. X
  1320. X#define MAX_FILES 10
  1321. X
  1322. Xstatic struct file 
  1323. X    {
  1324. X    FILE *fd;            /* which file */
  1325. X    long offset,        /* where are we reading from now */
  1326. X         top;            /* where is the notional start */
  1327. X    } file_table[MAX_FILES];
  1328. X    
  1329. X
  1330. Xvoid
  1331. Xmyopen(which,file)
  1332. X
  1333. Xint which;
  1334. XFILE *file;
  1335. X
  1336. X{
  1337. Xfile_table[which].fd=file;
  1338. Xfile_table[which].offset=file_table[which].top=ftell(file);
  1339. X}
  1340. X
  1341. Xmyisopen(which)
  1342. X
  1343. Xint which;
  1344. X
  1345. X{
  1346. Xreturn file_table[which].fd != NULL;
  1347. X}
  1348. X
  1349. Xchar *
  1350. Xmygets(buffer,num,which)
  1351. X
  1352. Xchar *buffer;
  1353. Xint num;
  1354. Xint which;
  1355. X{
  1356. X    fseek(file_table[which].fd,file_table[which].offset,0);
  1357. X
  1358. X    buffer=fgets(buffer,num,file_table[which].fd);
  1359. X
  1360. X    file_table[which].offset=ftell(file_table[which].fd);
  1361. X
  1362. X    return buffer;
  1363. X    }
  1364. X
  1365. Xvoid
  1366. Xmyrewind(which)
  1367. X
  1368. Xint which;
  1369. X
  1370. X{
  1371. X    fseek(file_table[which].fd,file_table[which].top,0);
  1372. X    file_table[which].offset=file_table[which].top;
  1373. X    }
  1374. X
  1375. Xvoid
  1376. Xmyclose(which)
  1377. X
  1378. Xint which;
  1379. X
  1380. X{
  1381. X    int i;
  1382. X
  1383. X    for(i=0;i<MAX_FILES;i++)
  1384. X    if ( i != which && file_table[i].fd == file_table[which].fd)
  1385. X        {
  1386. X        file_table[which].fd=NULL;
  1387. X        return;
  1388. X        }
  1389. X
  1390. X    fclose(file_table[which].fd);
  1391. X    }
  1392. X
  1393. SHAR_EOF
  1394. chmod 0644 file.c || echo "restore of file.c fails"
  1395. sed 's/^X//' << 'SHAR_EOF' > file.h &&
  1396. X/*********************************************************************
  1397. X*                                                                    *
  1398. X* file manipulations                                                 *
  1399. X*                                                                    *
  1400. X*********************************************************************/
  1401. X
  1402. Xvoid myopen();
  1403. Xint isopen();
  1404. Xchar *mygets();
  1405. Xvoid myrewind();
  1406. Xvoid myclose();
  1407. X
  1408. SHAR_EOF
  1409. chmod 0644 file.h || echo "restore of file.h fails"
  1410. sed 's/^X//' << 'SHAR_EOF' > patchV4.6 &&
  1411. X*** onotes.v4    Wed Sep 20 21:40:57 1989
  1412. X--- notes.v4    Wed Sep 20 21:41:22 1989
  1413. X***************
  1414. X*** 185,194 ****
  1415. X  133. added fix to make sure '-p' command checks void properly. [D. Caplinger]
  1416. X  134. inserted a check for allowing extra clear when redrawing.
  1417. X  135. renamed all of the conqps source files to 'psmap'.
  1418. X  
  1419. X  -------------------------------------------------------------------------
  1420. X! | 2.0 POSSIBLE SHORT-TERM ENHANCEMENTS/FIXES FOR CONQUER V4             |
  1421. X  -------------------------------------------------------------------------
  1422. X  o make land capture only occur during update.
  1423. X  o some problems due to two nations capturing same land.  should fix by above.
  1424. X  o some problems with MINER not providing initial stats on first turn after
  1425. X--- 185,273 ----
  1426. X  133. added fix to make sure '-p' command checks void properly. [D. Caplinger]
  1427. X  134. inserted a check for allowing extra clear when redrawing.
  1428. X  135. renamed all of the conqps source files to 'psmap'.
  1429. X+ ===4.0 patch number five released => 4.5 ===========================
  1430. X+ 136. changed situations of string printing mvprintw's to mvaddstr's.
  1431. X+ 137. moved a 'makebottom()' from 'm'ove command to parse routine.
  1432. X+ 138. npc.c (1339): added a check for ntn[country].tciv > 0 [T. Kivinen]
  1433. X+ 139. reset both roads_this_turn and terror_adj in login change. [T. Kivinen]
  1434. X+ 140. fixed overflow on wealth calculations [K. Bera]
  1435. X+ 141. adjusted flee() code for incremental people adjustment [K. Bera]
  1436. X+ 142. added patch to include XENIX header file in update.c [J. Bayer]
  1437. X+ 143. fixed passing of a parameter in god_magk() call.
  1438. X+ 144. fixed highlight function call three places in move.c.
  1439. X+ 145. fixed prep function call in move.c and io.c.
  1440. X+ 146. fixed get_display_for function call in display.c.
  1441. X+ 147. adjusted txt1 to clarify attractiveness calculation. {9 per jewels
  1442. X+     was written as 9 / jewels.  Changed it to 9 * jewels.} [T. Kivenen]
  1443. X+ 148. implemented the command 'X' to center screen around a nations capitol.
  1444. X+ 149. implemented the command 'x' to center screen around given sector.
  1445. X+ 150. in god mode, the 'X' command jumps between active nations' capitols.
  1446. X+ 151. centered screen about captitol during initial login.
  1447. X+ 152. gave god the ability to move civilians using 'Z' {#ifdef OGOD}.
  1448. X+ 153. altered calcuation of both poverty and inflation and added to txt5.
  1449. X+ 154. changed F_OK to 00 in update.c.
  1450. X+ 155. rewrote the isinstr() function in psmap.c to avoid the use of index().
  1451. X+ 156. implemented tests throughout find_avg_sector() for zero division.
  1452. X+ 157. changed astr,dstr to floats in combat.c (198).  [Bob Earl]
  1453. X+ 158. added use of indicator instead of using MGKNUM in combat.c. [T. Kivinen]
  1454. X+ 159. added extra check in land_reachp() for movecost < 0.  [Dean Brooks]
  1455. X+ 160. removed MOVECOST from 'd'isplay command.
  1456. X+ 161. altered bottom display of move() after error messages.
  1457. X+ 162. added makebottom() to civilian movement, was accidently removed(?)
  1458. X+ 163. big adjustment to mining_ability and wealth:
  1459. X+     -if it is lowered, it decreases by only a quarter of the difference.
  1460. X+ 164. fixed typo and checking of placed in terraform() [Dean Brooks]
  1461. X+ 165. added in dgod_make flag to indicate if the demi-god is remaking.
  1462. X+ 166. added setting of spell points to zero in zeroworld().
  1463. X+ 167. renamed dgod_make to remake and made demi-god be default for any remake.
  1464. X+ 168. changed the clear(); in change() to move(0,0); clrtobot();
  1465. X+ 169. added move(0,0), etc. to fleetrpt() and armyrpt().
  1466. X+ 170. moved the makebottom(); to parse after the EXT_CMD entry.
  1467. X+ 171. added move(0,0), etc. to fleetrpt() and armyrpt().
  1468. X+ 172. added move(0,0), etc. to trade() in trade.c.
  1469. X+ 173. made major adjustments to the mailing routines mailopen() mailclose().
  1470. X+ 174. rewrote the mail interface to be a little more robust.
  1471. X+ 175. the mail writing and reading routines now prevent most conflicts.
  1472. X+ 176. made the mail writer a little spiffier.
  1473. X+ 177. fixed a bug in detection of leader death and recreation in update.c.
  1474. X+ 178. no longer charge BREAKJIHAD for breaking one-sided treaties.
  1475. X+ 179. added in fix to ruin redesignation when DERVISH or DESTROYER.
  1476. X+ 180. allow redesignation of ruin to a non-city type at REBUILDCOST cost.
  1477. X+ 181. altered the god_mgk() display routine a little.
  1478. X+ 182. added in a limit of 16% to charity creeping for democracy.
  1479. X+ 183. added a check for a line with a period on it to end mail.
  1480. X  
  1481. X  -------------------------------------------------------------------------
  1482. X! | 2.0 POSSIBLE SHORT-TERM ENHANCEMENTS/FIXES FOR CONQUER V5             |
  1483. X  -------------------------------------------------------------------------
  1484. X+ o new functions:
  1485. X+     - status_value() = returns base values of attack.defend,etc.
  1486. X+     - sect_movecost() = returns move cost for given unit in given sector.
  1487. X+ o adding to grouped soldiers with ZERO movement should not change status.
  1488. X+ o changes to zombies:
  1489. X+     - should need less food.
  1490. X+     - some should decay each turn. [5% or so]
  1491. X+     - drafting zombies should decrease popularity. [just killed people!]
  1492. X+     - zombie formation could be a factor of nation being in battle not
  1493. X+       neccesarily having zombies in battle.  OR limit number of zombies
  1494. X+           created to be half or third size of zombie armies, since zombies
  1495. X+           are needed to create other zombies.
  1496. X+ o new display options:
  1497. X+     - highlight units who haven't moved since start of turn.
  1498. X+ o multiple leaders in a unit?  [then experience is not able to be
  1499. X+     added in later.]
  1500. X+ o limit spell points via knowledge, or cause lose based on knowledge factor.
  1501. X+ o might scroll screen without moving sector.  [What keys?  Needed?]
  1502. X+ o implement automatic updates through use of checking what nations have
  1503. X+     moved.
  1504. X+ o additional extended commands:  [ESC prefix]
  1505. X+     'r' = Renumber an army.  [new army structure could facilitate]
  1506. X+     'j' = Jump to location of given army number.
  1507. X+ o additional commands:
  1508. X+     'O' = go to previous army.
  1509. X+ o implement interface for 'Z' command.  [Movement locator]
  1510. X+ o email to real diety. [hmmm... needed or not?  I would actually vote
  1511. X+     for allowing mail to both the diety and the demi-god. -adb]
  1512. X  o make land capture only occur during update.
  1513. X  o some problems due to two nations capturing same land.  should fix by above.
  1514. X  o some problems with MINER not providing initial stats on first turn after
  1515. X*** oheader.h    Wed Sep 20 21:40:55 1989
  1516. X--- header.h    Wed Sep 20 21:41:22 1989
  1517. X***************
  1518. X*** 162,167 ****
  1519. X--- 162,168 ----
  1520. X                     for cities                */
  1521. X  #define FORTCOST    1000L    /* cost to build a fort point        */
  1522. X  #define STOCKCOST    3000L    /* cost to build a stockade        */
  1523. X+ #define REBUILDCOST    3000L    /* cost to remove a ruin        */
  1524. X  #define WARSHPCOST    20000L    /* cost to build one light warship    */
  1525. X  #define MERSHPCOST    25000L    /* cost to build one light merchant    */
  1526. X  #define GALSHPCOST    25000L    /* cost to build one light galley    */
  1527. X*** odata.h    Wed Sep 20 21:40:54 1989
  1528. X--- data.h    Wed Sep 20 21:41:23 1989
  1529. X***************
  1530. X*** 18,23 ****
  1531. X--- 18,28 ----
  1532. X  #define    FALSE        0
  1533. X  #endif
  1534. X  
  1535. X+ /* definitions for mail sending */
  1536. X+ #define    DONEMAIL    (-3)
  1537. X+ #define    NEWSMAIL    (-2)
  1538. X+ #define    ABORTMAIL    (-1)
  1539. X+ 
  1540. X  /* definitions for screen redrawing */
  1541. X  #define    DONE    0
  1542. X  #define    PART    1
  1543. X***************
  1544. X*** 498,503 ****
  1545. X--- 503,509 ----
  1546. X  #define XNAGAL        30
  1547. X  #define XNAHOLD        31
  1548. X  #define NPOP        32
  1549. X+ #define XSACIV3    33
  1550. X  
  1551. X  #define    BRIBENATION fprintf(fm,"L_NGOLD\t%d\t%d\t%ld\t0\t%d\t%s\n",XBRIBE,country,bribecost,nation,"null");
  1552. X  #define    DESTROY fprintf(fexe,"DESTROY\t%d\t%d\t%hd\t0\t0\t%s\n",DESTRY,save,country,"null")
  1553. X***************
  1554. X*** 523,528 ****
  1555. X--- 529,535 ----
  1556. X  #define    SADJDES2    fprintf(fexe,"S_ADES\t%d\t%hd\t0\t%d\t%d\t%c\n",XSADES,country,x,y,sct[x][y].designation)
  1557. X  #define    SADJCIV2 fprintf(fexe,"S_ACIV\t%d\t%hd\t%ld\t%d\t%d\t%s\n",XSACIV,country,sct[i][j].people,i,j,"null")
  1558. X  #define    SADJCIV    fprintf(fexe,"S_ACIV\t%d\t%hd\t%ld\t%d\t%d\t%s\n",XSACIV,country,sct[xcurs+xoffset][ycurs+yoffset].people,xcurs+xoffset,ycurs+yoffset,"null")
  1559. X+ #define    SADJCIV3 fprintf(fexe,"S_ACIV3\t%d\t%hd\t%ld\t%d\t%d\t%s\n",XSACIV3,country,people_to_add,i,j,"null")
  1560. X  #define    INCFORT fprintf(fexe,"SIFORT\t%d\t%hd\t0\t%d\t%d\t%s\n",XSIFORT,country,xcurs+xoffset,ycurs+yoffset,"null")
  1561. X  #define    SADJOWN    fprintf(fexe,"S_AOWN\t%d\t%hd\t0\t%d\t%d\t%s\n",XSAOWN,country,xcurs+xoffset,ycurs+yoffset,"null")
  1562. X  #define    EADJDIP(a,b)    fprintf(fexe,"E_ADJ\t%d\t%hd\t%d\t%d\t0\t%s\n",EDADJ,a,b,ntn[a].dstatus[b],"null")
  1563. X***************
  1564. X*** 612,618 ****
  1565. X  
  1566. X  extern int    move_file(), land_2reachp(), land_reachp(), canbeseen();
  1567. X  extern int    water_reachp(), markok(), is_habitable(), parse();
  1568. X! extern int    units_in_sector(), num_powers(), tofood();
  1569. X  extern int    get_god(), flightcost(), todigit(), getclass(), startcost();
  1570. X  extern int    water_2reachp(),tg_ok(), readmap(), avian();
  1571. X  extern int    cbonus(), armymove(),takeover(),getnewname();
  1572. X--- 619,625 ----
  1573. X  
  1574. X  extern int    move_file(), land_2reachp(), land_reachp(), canbeseen();
  1575. X  extern int    water_reachp(), markok(), is_habitable(), parse();
  1576. X! extern int    units_in_sector(), num_powers(), tofood(), mailopen();
  1577. X  extern int    get_god(), flightcost(), todigit(), getclass(), startcost();
  1578. X  extern int    water_2reachp(),tg_ok(), readmap(), avian();
  1579. X  extern int    cbonus(), armymove(),takeover(),getnewname();
  1580. X***************
  1581. X*** 628,634 ****
  1582. X  extern struct    s_sector *rand_sector();
  1583. X  extern void    subgships(),submships(),subwships(),getspace(),sackem();
  1584. X  extern void    sleep(), whatcansee(), reset_god(), get_nname(), camp_info();
  1585. X! extern void    main(), makebottom(), makeside(), check_mail();
  1586. X  extern void    checkout(),copyscreen(),bye(),credits(),init_hasseen();
  1587. X  extern void    combinearmies(),change_status(),reducearmy(),splitarmy();
  1588. X  extern void    errormsg(), clear_bottom(), addgroup(),ext_cmd();
  1589. X--- 635,641 ----
  1590. X  extern struct    s_sector *rand_sector();
  1591. X  extern void    subgships(),submships(),subwships(),getspace(),sackem();
  1592. X  extern void    sleep(), whatcansee(), reset_god(), get_nname(), camp_info();
  1593. X! extern void    main(), makebottom(), makeside(), check_mail(), centermap();
  1594. X  extern void    checkout(),copyscreen(),bye(),credits(),init_hasseen();
  1595. X  extern void    combinearmies(),change_status(),reducearmy(),splitarmy();
  1596. X  extern void    errormsg(), clear_bottom(), addgroup(),ext_cmd();
  1597. X***************
  1598. X*** 635,642 ****
  1599. X  extern void    randomevent(), wdisaster(), weather(), deplete();
  1600. X  extern void    verify_ntn(), verify_sct(), verifydata(), prep();
  1601. X  extern void    errorbar(), newbye(), newreset(), newmsg(), newerror();
  1602. X! extern void    newinit();
  1603. X! extern void    destroy(), updmove(), spreadsheet(), mailopen(), mailclose();
  1604. X  extern void    updexecs(), updcapture(), updsectors();
  1605. X  extern void    updmil(), updcomodities(), updleader();
  1606. X  extern void    nationrun(), n_atpeace(), n_trespass(), n_people();
  1607. X--- 642,649 ----
  1608. X  extern void    randomevent(), wdisaster(), weather(), deplete();
  1609. X  extern void    verify_ntn(), verify_sct(), verifydata(), prep();
  1610. X  extern void    errorbar(), newbye(), newreset(), newmsg(), newerror();
  1611. X! extern void    newinit(), jump_to();
  1612. X! extern void    destroy(), updmove(), spreadsheet(), mailclose();
  1613. X  extern void    updexecs(), updcapture(), updsectors();
  1614. X  extern void    updmil(), updcomodities(), updleader();
  1615. X  extern void    nationrun(), n_atpeace(), n_trespass(), n_people();
  1616. X***************
  1617. X*** 653,659 ****
  1618. X  extern void    mymove(),navalcbt(),newdip(),newdisplay(),newlogin();
  1619. X  extern void    newspaper(),npcredes(),offmap(),place(),populate();
  1620. X  extern void    printele(),printnat(),printscore(),printveg();
  1621. X! extern void    pr_ntns(),produce();
  1622. X  extern void    readdata(),redesignate(),redomil(),reduce(),rmessage(),score();
  1623. X  extern void    see(),showscore(),update();
  1624. X  extern void    wmessage(),writedata(),getdstatus(),exit();
  1625. X--- 660,666 ----
  1626. X  extern void    mymove(),navalcbt(),newdip(),newdisplay(),newlogin();
  1627. X  extern void    newspaper(),npcredes(),offmap(),place(),populate();
  1628. X  extern void    printele(),printnat(),printscore(),printveg();
  1629. X! extern void    pr_ntns(),pr_desg(),produce();
  1630. X  extern void    readdata(),redesignate(),redomil(),reduce(),rmessage(),score();
  1631. X  extern void    see(),showscore(),update();
  1632. X  extern void    wmessage(),writedata(),getdstatus(),exit();
  1633. X*** oadmin.c    Wed Sep 20 21:40:53 1989
  1634. X--- admin.c    Wed Sep 20 21:41:23 1989
  1635. X***************
  1636. X*** 39,44 ****
  1637. X--- 39,47 ----
  1638. X  short    country=0;
  1639. X  struct    s_nation    *curntn;
  1640. X  extern char datadir[];
  1641. X+ #ifdef REMAKE
  1642. X+ int    remake=FALSE;
  1643. X+ #endif /*REMAKE*/
  1644. X  
  1645. X  FILE *fexe, *fopen();
  1646. X  
  1647. X***************
  1648. X*** 53,59 ****
  1649. X      void srand();
  1650. X      int getopt();
  1651. X      long time();
  1652. X!     /* mflag = makeworld, a=add player, x=execute, p=print */
  1653. X      /* rflag = make world from read in files */
  1654. X      int mflag, aflag, xflag, rflag;
  1655. X      char string[FILELTH];
  1656. X--- 56,62 ----
  1657. X      void srand();
  1658. X      int getopt();
  1659. X      long time();
  1660. X!     /* mflag = make world, a=add player, x=execute, p=print */
  1661. X      /* rflag = make world from read in files */
  1662. X      int mflag, aflag, xflag, rflag;
  1663. X      char string[FILELTH];
  1664. X***************
  1665. X*** 201,206 ****
  1666. X--- 204,212 ----
  1667. X                  printf(".\n");
  1668. X                  exit(FAIL);
  1669. X              }
  1670. X+ #ifdef REMAKE
  1671. X+             remake=TRUE;
  1672. X+ #endif /*REMAKE*/
  1673. X              printf("************* WARNING!!!! *******************\n\n");
  1674. X              printf("    There is already a game in progress.\n\n");
  1675. X              printf("*********************************************\n\n");
  1676. X***************
  1677. X*** 485,494 ****
  1678. X          temp=1000*curntn->score/WORLDSCORE + 1000*curntn->tmil/WORLDMIL;
  1679. X          curntn->power = min(temp/5,MAXTGVAL);
  1680. X  
  1681. X          temp = curntn->tgold;
  1682. X          if(temp<0) temp=0;
  1683. X!         temp = 1000*temp/WORLDGOLD + 1000*curntn->jewels/WORLDJEWELS + 1000*curntn->metals/WORLDMETAL + cityfolk*5/3 + townfolk*5/6;
  1684. X!         curntn->wealth = min( temp/10,MAXTGVAL );
  1685. X  
  1686. X          if( TURN!= 1) {
  1687. X          curntn->reputation += rand()%8-3;
  1688. X--- 491,505 ----
  1689. X          temp=1000*curntn->score/WORLDSCORE + 1000*curntn->tmil/WORLDMIL;
  1690. X          curntn->power = min(temp/5,MAXTGVAL);
  1691. X  
  1692. X+         /* calculate national wealth */
  1693. X          temp = curntn->tgold;
  1694. X          if(temp<0) temp=0;
  1695. X!         temp = (long)(1000.0*temp/WORLDGOLD + 1000.0*curntn->jewels/WORLDJEWELS + 1000.0*curntn->metals/WORLDMETAL) + cityfolk*5/3 + townfolk*5/6;
  1696. X!         if (temp >= curntn->wealth) {
  1697. X!             curntn->wealth = min( temp/10,MAXTGVAL );
  1698. X!         } else {
  1699. X!             curntn->wealth -= (curntn->wealth - temp)/4;
  1700. SHAR_EOF
  1701. echo "End of part 1, continue with part 2"
  1702. echo "2" > s2_seq_.tmp
  1703. exit 0
  1704.